{% extends 'base.html' %}
{% load breadcrumps %}

{% block title_suffix %}
    | {{ page.title }}
{% endblock %}

{% block content %}
{% block page_content %}
	{% breadcrumps page %}

	{% comment %}
	Enable HTML for the page's content	{% endcomment %}
	{% autoescape off %}
		
		<div id="page-content">
			{% if user.is_staff and not request.session.viewing_as_student %}				
				<!-- Modal for creating exercise -->
				<div id="create-exercise-modal" class="modal hide fade">
				    <div class="modal-header">
					    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					    <h3>Create a Test</h3>
				    </div>
				    <div class="modal-body">
				    	{% include '_create_test.html' %}
				    </div>
				    <div class="modal-footer">
					    <button class="btn" type="button" data-dismiss="modal">Cancel</button>
				    </div>
			    </div>

			    <!-- Header buttons -->
				<div class="btn-group pull-right">
					{% block page_buttons %}
						<a href="#create-exercise-modal" role="button" class="btn" data-toggle="modal">
							<i class="icon-wrench"></i> Create test..
						</a>
					{% endblock %}

					<a href="{% url 'page.views.edit' page_id=page.id %}" class="btn btn-primary" type="button">
						<i class="icon-edit icon-white"></i> Edit page content
					</a>
				</div>
			{% endif %}
				<!-- Page Title -->
				<div class="page-header">
					<h1><strong>{{ page.title }}</strong> {% block sub_title %}{% endblock %}</h1>
				</div>
			{% if user.is_staff and not request.session.viewing_as_student %}
				<!-- Creator/modifier info box -->
				<div class="alert alert-info">
					<table cellpadding="4">
						<tbody>
							<tr>
								<td style="text-align: right;"><strong>Modified by: </strong></td>
								<td>{{ page.changer.first_name }} {{ page.changer.last_name }}</td>
								<td>{{ page.modified }}</td>
								<td></td>
								<td style="text-align: right;"><strong>Created by: </strong></td>
								<td>{{ page.creator.first_name }} {{ page.creator.last_name }}</td>
								<td>{{ page.created }}</td>
							</tr>
						</tbody>
					</table>
				</div>
			{% endif %}
				
				<!-- Page Content -->
				<p>{{ page.get_content }}</p>
				
			</div>
	{% endautoescape %}
{% endblock %}

{% block page_footer %}
	<!-- Navigation Footer -->
	<div class="form-actions">
		{% if prev %}
			<a href="{{ prev.get_absolute_url }}" class="btn btn-small"><i class="icon-chevron-left"></i> {{ prev.title }}</a>
		{% else %}
			<a href="{% url 'page.views.my_progress' %}" class="btn btn-small"><i class="icon-chevron-left"></i> My Progress</a>
		{% endif %}

			{% if next %}
			<a href="{{ next.get_absolute_url }}" class="btn btn-primary btn-small pull-right">{{ next.title }} <i class="icon-chevron-right icon-white"></i></a>
		{% else %}
			<a href="{% url 'page.views.my_progress' %}" class="btn btn-small pull-right">My Progress <i class="icon-chevron-right"></i></a>
		{% endif %}
	</div>
{% endblock %}
{% endblock %}

{% block scripts %}
	<script type="text/javascript" src="/static/script/setup_ajax.js"></script>
	{% if user.is_staff %}
		<script type="text/javascript" src="/static/script/page.admin.view_page.js"></script>
	{% endif %}
{% endblock %}